package com.yf1706.dao.jpa;

import java.util.Date;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.yf1706.bean.FloatSalary;
import com.yf1706.vo.CountFloatSalaryVO;
import com.yf1706.vo.FloatSalaryVO;

/**
 * 
 * @author 锦涛
 *
 */
public interface IFloatSalaryJDAO extends JpaRepository<FloatSalary, Integer>{

	@Query("SELECT new com.yf1706.vo.FloatSalaryVO(f.floatSalaryId, "
			+ "f.emp.empName, f.floatSalaryName, f.value, f.beginDate,"
			+ "f.endDate, f.mender, f.mendDate, f.remark) from FloatSalary f "
			+ "where f.floatSalarySob.floatSalarySobId = ?1")
	Page<FloatSalaryVO> findSearch (int id, Pageable pageable);
	
	@Query("SELECT new com.yf1706.vo.CountFloatSalaryVO(f.emp.empId, "
			+ "f.floatSalaryName, f.value) from FloatSalary f "
			+ "where f.floatSalarySob.floatSalarySobId = ?1 and"
			+ "((?2 between f.beginDate and f.endDate) or ?2 > f.beginDate)")
	List<CountFloatSalaryVO> findSearchBySidAndDate(int sId,Date countDate);
}
